/**
* @file        ILocSignalDeliver
* @brief       
* @version     1.0.0
* @author      Changlin.Jing;Chi.li
* @date        2023/2/16 14:13
* @copyright   Copyright  2022 Langge Software Co., Ltd. All rights reserved.
*/
#ifndef LANGGEBASE_ILOCSIGNALDELIVER_HPP
#define LANGGEBASE_ILOCSIGNALDELIVER_HPP

#include "ut_symbols.h"
#include "loc_signal_type.h"
#include <memory>
#include <utility>

BEGIN_SPACE_LANGE_VDR
enum LocSignalDeliverId {
    SIGNAL_DELIVER_LOC_SIGNAL_FILTER  = 0,      // 信号过滤
    SIGNAL_DELIVER_LOCATION_QUALITY_ESTIMATOR,  // 质量评估
    SIGNAL_DELIVER_ATTITUDE_ESTIMATOR,          // 姿态估计
    SIGNAL_DELIVER_POSITION_ESTIMATOR,          // 位置估计
    SIGNAL_DELIVER_SPEED_ESTIMATOR,             // 速度估计
    SIGNAL_DELIVER_COUNT
};


class ILocSignalDeliver {
public:
    ILocSignalDeliver(std::shared_ptr<ILocSignalDeliver> nextDeliver, LocSignalDeliverId deliverId) :mSignalDeliverId(deliverId), mNextDeliver(std::move(nextDeliver)) {

    }
    virtual ~ILocSignalDeliver() {
        if (nullptr != mNextDeliver) {
            mNextDeliver.reset();
        }
        mSignalDeliverId = SIGNAL_DELIVER_COUNT;
    }

    LocSignalDeliverId getSignalDeliverId() {
        return mSignalDeliverId;
    }

    std::shared_ptr<ILocSignalDeliver> getNextDeliver() {
        return mNextDeliver;
    }

    virtual void onSignal(std::shared_ptr<I_LOC_SIGNAL> locSignal) = 0;

protected:
    void callNext(const std::shared_ptr<I_LOC_SIGNAL>& locSignal) {
        if (mNextDeliver == nullptr) {
            return;
        }
        mNextDeliver->onSignal(locSignal);
    }

private:
    LocSignalDeliverId mSignalDeliverId;
    std::shared_ptr<ILocSignalDeliver> mNextDeliver;
};
END_SPACE_LANGE_VDR

#endif //LANGGEBASE_ILOCSIGNALDELIVER_HPP
